<include file="StoreZT:header"/>
<div class="wraper">
    <div class="operate">
        <p class="operate-theme pull-left note">我的收藏（<span>{BEESCRM:$count}</span>）</p>
        <a href="javascript:void(0);" class="operate-delete pull-left">删除</a>
    </div>
	<div class="product">
    <volist name="data" id="vo">
	    <div class="list-info collection">
	        <div class="checkbox">
	            <span class="iconfont icon-checkbox"></span>
	            <input type="checkbox" name="collection_id" value="{BEESCRM:$vo.collection_id}"/>
	        </div>
		    <a href="{BEESCRM::U('base/storeZT/goodsDetail/',array('goods_id'=>$vo['goods_id'],'origin'=>$origin,'store_id'=>$storeId))}">
	        <div class="product-img"><img src="{BEESCRM:$vo.goods_thumb}"/></div>
	        <div class="product-info">
	            <p>{BEESCRM:$vo.goods_name}</p>
	            <p class="prize">
	            	<span class="new-prize">￥{BEESCRM:$vo.goods_price}</span>
	            	<span class="old-prize">￥{BEESCRM:$vo.goods_original_price}</span>
	            </p>
	        </div>
		    </a>
	    </div>
	</volist>
	</div>
</div>
<include file="StoreZT:commonJs" />
<include file="StoreZT:footer" />
<script>
	$(document).ready(function(){
		$(document).ready(function(){
			var page = 2,
					url="/base/storeZT/doAjaxGetCollectionList/store_id/{BEESCRM:$storeId}",
					flag = true;

			$(window).scroll(function(){
				if(($(window).scrollTop() + $(window).height() > $(document).height() - 40)){
					if(flag) {
						flag = false;
						$.ajax({
							type:"GET",
							url:url,
							data:{'page': page},
							dataType:'json',
							beforeSend:function(){
								$('.data-loding').show();//显示加载时候的提示
							},
							success:function(data){
								var str ='';
								if(data.status=='S'){
									if(data.data.length > 0) {
										$('.data-loding').hide();
										$.each(data.data,function(i,k){
											var goods_id = k.goods_id;
											var url= 'store/user/goodsDetail/goods_id/'+goods_id+'/origin/{BEESCRM:$origin}/did/{BEESCRM:$did}';
											str += '<div class="list-info collection">'
											+'<div class="checkbox">'
											+'<span class="iconfont icon-checkbox"></span>'
											+'<input type="checkbox"/>'
											+'</div>'
											+'<a href="'+url+'"><div class="product-img"><img src="'+k.goods_thumb+'"/></div>'
											+'<div class="product-info">'
											+'<p>'+k.goods_name+'</p>'
											+'<p class="prize">'
											+'<span class="new-prize">'+k.goods_price+'</span>'
											+'<span class="old-prize">￥'+k.goods_original_price+'</span>'
											+'</p>'
											+'</div></a>'
											+'</div>';
										});
										$(".product").append(str);
										page++;
										flag = true;
									} else {
										$('.data-loding').hide();
										flag = false;
									}
								}
							}
						});
					}
				}
			})
		})
	});

	$(function(){
		$('.checkbox').click(function(){
			$(this).find('span').toggleClass('icon-xuanzedianjihou');
			$(this).find('input').attr('checked',true);
		})
	});
	
	//删除收藏商品
	$(document).on('click','.operate-delete',function(){
		var collection_id=[];
		var json={};
		$('input[name="collection_id"]:checked').each(function(){
			collection_id.push($(this).val());
		});
		if(collection_id.length<1){
			$.alert('error','请先选择商品');return false;
		}
		json.url='{BEESCRM::U("base/storeZT/doDeleteCollection",array('store_id'=>$storeId))}';
		json.method='post';
		json.type='json';
		json.data={'collection_id':collection_id};
		$.getAjax(json,true,reload);
	});
	
	function reload(){
		setTimeout('location.reload()',3000);
	}
</script>